package top.hidoctor.auscultation.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.alexvasilkov.gestures.views.GestureImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import java.util.ArrayList;
import java.util.List;

public class AdapterViewpager extends PagerAdapter {
    private List<String> mViewList;
    private List<GestureImageView>list=new ArrayList<>();
    public AdapterViewpager(List<String> mViewList) {
        this.mViewList = mViewList;
    }

    @Override
    public int getCount() {//必须实现
        return mViewList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {//必须实现
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {//必须实现，实例化
        GestureImageView gestureImageView=new GestureImageView(container.getContext());
        container.addView(gestureImageView);
        list.add(gestureImageView);
        Glide.with(container.getContext()).load(mViewList.get(position)).into(gestureImageView);
        return gestureImageView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {//必须实现，销毁
        container.removeView(list.get(position));
    }
}
